<template>
    <div class="page">
      <heads></heads>

      <div class="page-content" style="width: 100%;padding-bottom: 80px">
        <!-- <div style="padding-bottom:100px;"> -->
          <div class="user_cont">
            <!---未登录-->
            <div style="padding: 10px 0 5px;">
              <img src="../assets/180359344.jpg" width="70px" height="70px" style="    border: 1px solid #1b1f2e;border-radius: 70px;"/>
            </div>
            <div v-if="islogin=='false'||islogin==undefined" style="margin-top: 10px">
              <mt-button @click='$router.push("/login")' class="nogin" >未登录</mt-button>
            </div>
            <!--已登录-->
            <div v-else>
              <div style="margin-bottom: 9px">昵称:{{name}}</div>
              <!-- <div style="margin-bottom: 12px">&nbsp;</div> -->
              <div class="ky_jb">
                <div style="border-right: 1px solid  #ededed">获得奖励：<span style="color: #ff7800;">{{income}}</span></div>
                <div>可用金币：<span style="color: #ff7800">{{$store.state.moneys}}</span></div>
              </div>
            </div>
          </div>
          <div v-if="islogin=='true'" style="border-top: 5px solid rgb(237, 237, 237);padding:10px 15px;">
                <mt-button size="small" type="danger" @click='$router.push("/pay")' style="margin-right:40%;">充值</mt-button>
                <mt-button size="small" type="danger" @click='$router.push("/prize")'  >提现</mt-button><!--applymoney-->
          </div>
          <div style="    border-top: 5px solid #ededed;" class="list_xz">
            <mt-cell title="充值中心" :to='islogin=="false"||islogin==undefined?"/login":"/pay"' is-link></mt-cell>
             <!-- <mt-cell title="提现" :to='islogin=="false"||islogin==undefined?"/login":"/applymoney"' is-link></mt-cell> -->
            <mt-cell title="兑换奖品" :to='islogin=="false"||islogin==undefined?"/login":"/prize"' is-link></mt-cell>
            <mt-cell title="竞猜记录" :to='islogin=="false"||islogin==undefined?"/login":"/record"' is-link></mt-cell>
            <mt-cell title="实名认证" :to='islogin=="false"||islogin==undefined?"/login":"/information"' is-link></mt-cell>
            <mt-cell title="绑定银行卡" :to='islogin=="false"||islogin==undefined?"/login":"/bindbank"' is-link></mt-cell>
            <mt-cell title="竞猜介绍" to='/help' is-link></mt-cell>
          </div>
          <div class="loginOUt" v-if="islogin=='true'">
            <div @click="loginOut" >退出登录</div>
          </div>
          <footers></footers>
        <!-- </div> -->
      </div>

    </div>
</template>
<script>
  import heads from '../components/header'
  import footers from '../components/footer'
  import { Loadmore,Toast ,MessageBox } from 'mint-ui';
  import MtButton from "../../node_modules/mint-ui/packages/button/src/button";
  export default {
    data(){
      return{
        islogin:sessionStorage.getItem('login'),
        name:'',
        income:''
      }
    },
    mounted(){
      var _this=this;
//      if(_this.islogin=="true"){
        this.$http(this.API.coin,{data:{}}).then(function(res) {
            if(res.flag==1){
              sessionStorage.setItem('login', true)
              _this.islogin=sessionStorage.getItem('login');
              _this.$store.state.moneys=res.amount;
              _this.name=res.username;
              _this.income=res.income
            }
        }).catch(function(err) {
          console.log(err);
        });
//        return false
//      }
    },
    methods:{



       ///退出登录
      loginOut:function () {
        var _this=this;
        MessageBox.confirm('',{
          message: '确认退出',
          //title: '确认竞猜',
        }).then(action => {
          this.$http(this.API.logout,{
            data:{}
          }).then(function(res) {
            Toast({
              message: res.message,
              iconClass: 'icon'+res.flag==1?'icon-success':'icon-error',
              duration: 2000
            });
            if(res.flag){
              sessionStorage.setItem('login', false)
              _this.islogin=sessionStorage.getItem('login');
//              _this.$store.state.login=false;
            }
          }).catch(function(err) {
            console.log(err);
          });
        },()=>{//取消
          //alert(87)
        });

      }
    },
    components: {
      MtButton,
      heads,
      footers
    }

  }
</script>
<style>
  @import "../sass/pageScss/user.scss";
</style>
